package com.example.uitmanagement;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Menu_Activity extends Activity {
	// array string menu
	private String[] values = new String[] { 
			"Thông Báo",
			"Đăng kí môn học",
			"Điểm",
			"Thời khóa biểu",
			"Thông tin"
		  	  };
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);
        ListView listView = (ListView) findViewById(R.id.list_activity_menu);   
        Show_listView(listView);
        listView.setOnItemClickListener(new OnItemClickListener() {
        	  @Override
        	  public void onItemClick(AdapterView<?> parent, View view,
        	    int position, long id) {
        	   /* Toast.makeText(getApplicationContext(),
        	      "Click ListItem Number " + position , Toast.LENGTH_LONG)
        	      .show();*/
        		 String s =(String) ((TextView) view.findViewById(R.id.textView_menu)).getText();
        		 if(s.equals("Đăng kí môn học"))	 {
        		Intent intent_registry = new Intent(getApplicationContext(),Activity_list_registry.class);
      			startActivity(intent_registry);	      			
        		 }
        		 
        	  }
        	}); 
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_menu, menu);
        return true;
    }
    public void Show_listView(ListView listView){    	 	

    	// First paramenter - Context
    	// Second parameter - Layout for the row
    	// Third parameter - ID of the TextView to which the data is written
    	// Forth - the Array of data
    	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.menu_row, R.id.textView_menu, values);
    	// Assign adapter to ListView
    	listView.setAdapter(adapter); 
    }
}
